kind
There are three principal kinds of data objects, literals, constants, and variables.
literal
A literals is a specific numeric or string value. 23 is a numeric literal, while
"hello" is a string literal. The many literal formats supported are described in
the following pages.
numeric literal
A numeric literal is a specific numeric value represented in one of the following formats:
character literal | 'x' | ASCII character between single quotes |
integer literal | 88110 | decimal digits |
decimal literal | 88.110 | decimal digits plus a decimal point |
scientific literal | . 88110d+5 | decimal number with power of 10 exponent |
hexadecimal literal | 0xDEADC0DE | 0x plus 0 to 16 hexadecimal digits |
octal literal | 0o37777777777 | 0o plus 0 to 22 octal digits |
binary literal | 0b0010100010101011 | 0b plus 0 to 64 binary digits |
SINGLE image | 0s3F880000 | 0s plus exactly 8 hexadecimal digits |
DOUBLE image | 0d4018000080000000 | 0d plus exactly 16 hexadecimal digits |
character literal
Character literals are single ASCII characters enclosed in single quotes, like 'x' or '!'.
Simple backslash codes like '\a', '\n', '\V', '\\', and '\"' are also valid
representations of non-printing characters. The valid backslash codes are the single
character backslash codes defined for string literals. Character literals are
unsigned bytes UBYTE.
Character literals are a convenient, efficient way to specify the numeric value of any single ASCII character. 'a' , '!', and '"' are equivalent to ASC("a") , ASC("!") , and ASC(CHR$(34)), but execute much faster. Remember, character literals represent the ASCII value of characters, so '5' does not represent the number 5, but 0x35 or 53. See Appendix A for character values of ASCII characters. The following code segment illustrates character literals:
FUNCTION CheckChars (n$)
'
FOR i = 1 TO LEN(n$)
' for
each character in n$
v = ASC(n$, i)
' v = value of character #i
SELECT CASE TRUE
CASE (v >= 'A') AND (v <= 'Z') : PRINT "Upper
case letter."
CASE (v >= 'a') AND (v <= 'z') : PRINT "Lower
case letter."
CASE (v >= '0') AND (v <= '9') : PRINT "DECimal
digit."
CASE (v = '.')
: PRINT "decimal point."
CASE (v = '$')
: PRINT "dollar sign."
CASE (v = '\t')
: PRINT "tab character."
CASE (v = '\\')
: PRINT "backslash character."
CASE ELSE
: PRINT "nothing interesting."
END SELECT
NEXT i
END FUNCTION